import Vue from 'vue'
import VueRouter from 'vue-router'
const Login = ()=> import('../components/Login')
const Register = ()  => import ('../components/Register')
const SnakesUpload = () => import('../components/SnackUpload')
const FuWenBen = ()=>import('../components/tinymce-editor');
const BlogHome = ()=>import('../components/BlogHome');
const BlogBody = () =>import('../components/BlogBody');
const ArticleRelease = () =>import('../components/ArticleRelease');
const BlogHomeList = () =>import('../components/BlogHomeList');
const BlogDetails = () =>import('../components/BlogDetails');
const BlogInfo= () => import('../components/BlogInfo')
const BlogPortUpdate= () => import('../components/BlogProtUpload')
const BackStage = ()=> import('../components/BackStage')
const Blog = () => import('../components/Blog');
const AdminBlog = () => import('../components/AdminBlog')
const BlogUpdate = () => import('../components/BlogUpdate')
const Test = () => import('../components/Test')


Vue.use(VueRouter)

//获取原型对象上的push函数
const originalPush = VueRouter.prototype.push
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

  const routes = [
  {
    path: '/',
    name: 'Home',
    component:BlogHome,
    redirect:'/BlogHome/BlogBody',
  },
    {
      path: '/test',
      name: 'Test',
      component:Test,
    },
    {
      path: '/login',
      name: 'Login',
      component: Login
    },
    {
       path:'/Fu',
      name:'Fu',
      component:FuWenBen
    },
    {
      path:'/register',
      name: 'Register',
      component: Register
    },
    {
      path:'/BlogHome',
      name:'BlogHome',
      component:BlogHome,
      redirect:'/BlogHome/BlogBody',
      children: [
        {
          path:'/BlogHome/BlogBody',
          name:'BlogHome',
          redirect:'/BlogHome/BlogList',
          component:BlogBody,
          children: [
            {
              path:'/BlogHome/BlogList',
              name:'BlogList',
              component:BlogHomeList
            },
            {
              path:'/BlogHome/BlogDetails',
              name:'BlogDetails',
              component:BlogDetails
            }
          ]
        },
        {
          path:'/BlogHome/ArticleRelease',
          name:'ArticleRelease',
          component:ArticleRelease
        },
        {
          path:'/BlogHome/info',
          name:'BlogInfo',
          component:BlogInfo
        },
        {
          path:'/BlogHome/port',
          name:'BlogPort',
          component:BlogPortUpdate
        },

      ]
    },
      {
      path: '/BackStage',
      name: 'BackStage',
      component:BackStage,
      redirect:'/AdminBlog',
      meta:{
        title:"后台管理"
      },
      children:[
          {
           path:'/Blog',
           name:'Blog',
          meta: {
             'title':'博客'
          },
          component:Blog,
          children: [
            {
              path:'/AdminBlog',
              name: 'AdminBlog',
              meta: {
                'title':'文章管理'
              },
              component:AdminBlog
            },
            {
              path:'/BlogUpdate',
              name: 'BlogUpdate',
              meta: {
                'title':'文章更新'
              },
              component:BlogUpdate
            }
          ]
        }
      ]
    }
]

const router = new VueRouter({
  mode: 'history',
  base:'/dist/',
  // base: process.env.BASE_URL,
  routes
})
export default router
